<?php
$dep_id=$data['dep_id'];
$app_date= $data['app_date'];
$_morning='未排班';
$_afternoon = '未排班';
$datalist=array();
require_once './connect.php';
//获取医生姓名和id
$sql = "SELECT doc_id,doc_name FROM _doctor where dep_id='$dep_id'";
$result = $conn->query($sql);
if($result->num_rows>0)
{
    while($row=$result->fetch_assoc()){
        $doc_name=$row['doc_name'];
        $doc_id=$row['doc_id'];
        //获取医生排班
        $sqltwo = "SELECT * FROM _appoint where doc_id='$doc_id' AND app_date='$app_date'";
        $resulttwo = $conn->query($sqltwo);
        if($resulttwo->num_rows>0)
        {
            while($rowtwo=$resulttwo->fetch_assoc()){
            $_time=$rowtwo['app_time'];
            if($_time==='0'){
                $_morning='已排班';
            }
            else if($_time==='1') {
                $_afternoon = '已排班';
            }}
        }
        $datasingle=array('doc_id'=>$doc_id,'doc_name'=>$doc_name,
            '_morning'=>$_morning,'_afternoon'=>$_afternoon);
        array_push($datalist,$datasingle);
        $_morning='未排班';
        $_afternoon = '未排班';
    }
}
$datalist=array('dataList' => $datalist);
$response=array(
    'resultCode'=>'0',
    'resultObject'=> $datalist,
    'resultMsg'=>'成功'
);
//echo 'test';
echo json_encode($response);
$conn->close();
?>